package com.sgb.contract.view.ui.details;

import android.content.Context;

import com.sgb.contract.BR;
import com.sgb.contract.R;
import com.sgb.contract.model.ContractOperationLogBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * OtherInfoAdapter
 * @author cyj
 */
public class OtherInfoAdapter extends BaseRecycleAdapter<ContractOperationLogBean> {

    public OtherInfoAdapter(Context context) {
        super(context, R.layout.contract_adapter_item_other_info, null);
    }

//    @BindingAdapter("bindAdapter2")
//    public static void recycleViewBindAdapter(XRecyclerView recyclerView, XRecyclerView.Adapter<ItemViewHolder> adapter) {
//        recyclerView.setAdapter(adapter);
//    }

    @Override
    public void convert(ItemViewHolder holder, ContractOperationLogBean bean) {
        holder.setBinding(BR.mContractOperationLogBean, bean);

    }

    @Override
    public void setDatas(List<ContractOperationLogBean> list) {
        if(null != list && list.size() > 1) {
            list.get(0).setFirstPosition();
            list.get(list.size() - 1).setLastPosition();
        }
        super.setDatas(list);
    }

    @Override
    public void addDatas(List<ContractOperationLogBean> list) {
        if(null != list && list.size() > 1 && getDatas().size() > 1) {
            getDatas().get(getDatas().size() - 1).setRecoveryLastPosition();
            list.get(list.size() - 1).setLastPosition();
        }
        super.addDatas(list);
    }
}
